package com.gxz.redis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*****
 * @author guxz4
 * @Description: com.itheima.controller.RedisController
 ****/
@RestController
@RequestMapping(value = "/redis")
public class RedisController {

    @Autowired
    private RedisTemplate redisTemplate;

    /***
     * 操作Redis
     * @return
     */
    @GetMapping(value = "/handler")
    public String handler(){
        //添加数据
        redisTemplate.boundValueOps("itheima").set("www.itheima.com");
        //获取数据
        return redisTemplate.boundValueOps("itheima").get().toString();
    }
}
